package day06.YiChang;

import sun.management.AgentConfigurationError;

import java.util.Scanner;

public class Lian04 {
    public static void main(String[] args) {
        Student s = new Student();
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名");
        String s1 = sc.nextLine();
        s.setName(s1);
        while (true) {
            System.out.println("请输入年龄");
            String ageStr = sc.nextLine();
            try {
                int age = Integer.parseInt(ageStr);
                s.setAge(age);
                break;
            } catch (NumberFormatException e) {
                System.out.println("请输入一个整数");
                continue;
//            } catch (RuntimeException e) {
            } catch (AgeOutOfBoundsException e) {
                System.out.println(e.toString());
                System.out.println("请输入符合年龄的整数");
                continue;
            }
        }

        System.out.println(s);
    }
}

